package testView;

import static org.junit.Assert.*;

import org.junit.Test;

import model.ClassImpl;
import model.AttributeImpl;
import model.OperationImpl;


//This test tests the ClassImpl.java, AttributeImpl.java, and OperationImpl.java Models
public class testClass {

	//This method tests the ClassImpl.java file
	@Test
	public void testClass(){
		ClassImpl testClass = new ClassImpl();
		String name = "Test Main";
		int sizeX = 5;
		int sizeY = 5;
		
		//initializes the name, x and y coordinate to the sizex and sizey
		testClass.getName();
		testClass.setWidth(sizeX);
		testClass.setHeight(sizeY);
		
		//test the functions that give you the name, x size, and y size, and origins
		testClass.getName();	
		testClass.getWidth();
		testClass.getHeight();
		testClass.getoX();
		testClass.getoY();
		
		//Assert Tests
		assertEquals(testClass.getWidth(), 5);
		assertEquals(testClass.getHeight(), 5);
		assertEquals(testClass.getoX(), 0);
		assertEquals(testClass.getoY(), 0);
	}
	
	
	//This method tests adding attributes to a class and the AttributeImpl.java file
	@Test
	public void testClassAttributes(){
		ClassImpl tClass = new ClassImpl("Test");
		int vecVal = 0;
		String testString = "c a : b";
		String testString1 = "z x : y";
		
		//adds attribute and verifies it has been correctly added
		tClass.addAttribute("a", "b", 'c');
		assertEquals(tClass.getAttributes().elementAt(vecVal).toString(), testString);
		
		//adds another attribute and verifies it has been correctly added and hasn't overwritten the first attribute
		tClass.addAttribute("x", "y", 'z');
		vecVal++;
		assertEquals(tClass.getAttributes().elementAt(vecVal-1).toString(), testString);
		assertEquals(tClass.getAttributes().elementAt(vecVal).toString(), testString1);
	}
	
	//This method tests adding operations to a class and the OperationImpl.java file
	@Test
	public void testClassOperations(){
		ClassImpl tClass1 = new ClassImpl("Test");
		String tString = "z x() : y";
		String tString1 = "c a() : b";
		int vecVal = 0;
		
		//adds operation and correctly verifies its insertion
		tClass1.addOperation("x", "y", 'z');
		assertEquals(tClass1.getOperations().elementAt(vecVal).toString(), tString);
		
		//adds another operation and verifies it has been correctly added and hasn't overwritten the first attribute
		tClass1.addOperation("a", "b", 'c');
		vecVal++;
		assertEquals(tClass1.getOperations().elementAt(vecVal-1).toString(), tString);
		assertEquals(tClass1.getOperations().elementAt(vecVal).toString(), tString1);
	}
}
